package com.huitu.whht.base.core.api.wr.lk;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.api.core.common.response.StatusRespBuilder;

import com.huitu.whht.base.core.api.wr.lk.entities.WrLkB;

import com.huitu.whht.base.core.api.wr.lk.entities.WrLkBQo;
import com.huitu.whht.base.core.api.wr.lk.service.IWrLkBService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * 说明: 湖泊基本信息表API,表名称: WR_LK_B <br/>
 * 日期: 2019-04-15
 * @author LiuCW
 */
@Component
@SzyCoreApiResource
@Path("wr/lk/b")
public class WrLkBResource extends AbstractApiResource {

    private static final Logger LOGGER = LoggerFactory.getLogger(WrLkBResource.class);

    private static final String UUID = "f8190d48-5cb7-41ee-a1fd-a8f9d5606c93";

    @Override
    public String getUUID() {
        return UUID;
    }

    @Autowired
    @SzyCoreApiService
    IWrLkBService wrLkBService;

    /**
     * @api {get} wr/lk/b/{lkCd:\\w{7}} [R][G]根据主键查询
     * @apiDescription [G]根据主键查询WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)select by primary key
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiSampleRequest wr/lk/b/F42A201
     * @apiParam   {String}         lkCd               【必须】湖泊代码
     * @apiSuccess {String}         lkCd               湖泊代码
     * @apiSuccess {String}         lkNm               湖泊名称
     * @apiSuccess {Double}         watA               水面面积
     * @apiSuccess {String}         sfwProp            咸淡水属性
     * @apiSuccess {Double}         avgDep             平均水深
     * @apiSuccess {Double}         maxDep             最大水深
     * @apiSuccess {Double}         lkV                湖泊容积
     * @apiSuccess {Date}           ts                 时间戳(时间格式 <font color='red'>yyyy-MM-dd HH:mm:ss</font>)
     * @apiSuccess {String}         nt                 备注
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     *  }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{lkCd:\\w{7}}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("lkCd") String lkCd) {
        LOGGER.info("根据主键查询 湖泊基本信息表,参数 lkCd:{}", lkCd);
        return Response.ok(ApiResultBuilder.create(this, wrLkBService.selectByPrimaryKey(lkCd))).build();
    }

    /**
     * @api {post} wr/lk/b/list [R][G]根据条件查询
     * @apiDescription [G]根据条件查询WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)select by filter
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiSampleRequest wr/lk/b/list
     * @apiParam   {List(String)}   lkCdList           (数组)湖泊代码
     * @apiParam   {String}         lkCd               湖泊代码
     * @apiParam   {String}         lkNm               湖泊名称
     * @apiParam   {Double}         watAMin            (最小)水面面积
     * @apiParam   {Double}         watAMax            (最大)水面面积
     * @apiParam   {List(String)}   sfwPropList        (数组)咸淡水属性
     * @apiParam   {Double}         avgDepMin          (最小)平均水深
     * @apiParam   {Double}         avgDepMax          (最大)平均水深
     * @apiParam   {Double}         maxDepMin          (最小)最大水深
     * @apiParam   {Double}         maxDepMax          (最大)最大水深
     * @apiParam   {Double}         lkVMin             (最小)湖泊容积
     * @apiParam   {Double}         lkVMax             (最大)湖泊容积
     * @apiParam   {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam   {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {String}         lkCd               湖泊代码
     * @apiSuccess {String}         lkNm               湖泊名称
     * @apiSuccess {Double}         watA               水面面积
     * @apiSuccess {String}         sfwProp            咸淡水属性
     * @apiSuccess {Double}         avgDep             平均水深
     * @apiSuccess {Double}         maxDep             最大水深
     * @apiSuccess {Double}         lkV                湖泊容积
     * @apiSuccess {Date}           ts                 时间戳
     * @apiSuccess {String}         nt                 备注
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     *  }]
     * }
     *
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     *  }],
     * "paging": {
     * "count": 3,
     * "total": 120,
     * "finale": false,
     * "index": 1
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectList(WrLkBQo filter) {
        PageUtils.startPageFromRang();
        LOGGER.info("根据条件查询 湖泊基本信息表,参数 WrLkBQo:{}", filter);
        return Response.ok(ApiResultBuilder.create(this, wrLkBService.selectList(filter))).build();
    }

    /**
     * @api {put} wr/lk/b [C][G]新增数据
     * @apiPrivate
     * @apiDescription [G]新增WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)add data
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiParam   {String}         lkCd               【必须】湖泊代码
     * @apiParam   {String}         lkNm               【必须】湖泊名称
     * @apiParam   {Double}         watA               水面面积
     * @apiParam   {String}         sfwProp            咸淡水属性
     * @apiParam   {Double}         avgDep             平均水深
     * @apiParam   {Double}         maxDep             最大水深
     * @apiParam   {Double}         lkV                湖泊容积
     * @apiParam   {Date}           ts                 时间戳(时间格式 <font color='red'>yyyy-MM-dd HH:mm:ss</font>)
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {Integer}        status             1:新增成功;0:新增失败.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据,通常包含新增数据的主键值
     * @apiSampleRequest wr/lk/b
     * @apiSuccessExample 新增成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":{
     *   "lkCd": "F42A201"
     *      }
     *   }
     * }
     @apiSuccessExample 新增失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":{
     *   "lkCd": "F42A201"
     *      }
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     * }
     * @apiUse exceptions
     */
    @PUT
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insert(WrLkB record) {
        LOGGER.info("新增 湖泊基本信息表,参数 WrLkB:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.insert(wrLkBService.insertSelective(record),record))).build();
    }

    /**
     * @api {post} wr/lk/b/insertBatch [C][G]批量新增数据
     * @apiPrivate
     * @apiDescription [G]批量新增WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)addBatch data
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiParam   {String}         lkCd               【必须】湖泊代码
     * @apiParam   {String}         lkNm               【必须】湖泊名称
     * @apiParam   {Double}         watA               水面面积
     * @apiParam   {String}         sfwProp            咸淡水属性
     * @apiParam   {Double}         avgDep             平均水深
     * @apiParam   {Double}         maxDep             最大水深
     * @apiParam   {Double}         lkV                湖泊容积
     * @apiParam   {Date}           ts                 时间戳(时间格式 <font color='red'>yyyy-MM-dd HH:mm:ss</font>)
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {Integer}        status             1:新增成功;0:新增失败.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据,通常包含新增数据的主键值
     * @apiSampleRequest wr/lk/b/insertBatch
     * @apiSuccessExample 新增成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":{
     *   "lkCd": "F42A201"
     *      }
     *   }
     * }
     @apiSuccessExample 新增失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":{
     *   "lkCd": "F42A201"
     *      }
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * [{
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     * }]
     * @apiUse exceptions
     */
    @POST
    @Path("insertBatch")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insertBatch(List<WrLkB> recordList) {
        LOGGER.info("批量新增 湖泊基本信息表,参数 WrLkB:[]", recordList);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.insert(wrLkBService.insertBatch(recordList),recordList))).build();
    }

    /**
     * @api {put} wr/lk/b/{lkCd:\\w{7}}/update [U][G]根据主键修改
     * @apiPrivate
     * @apiDescription [G]根据主键修改WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)update data
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiParam   {String}         lkCd               【必须】湖泊代码
     * @apiParam   {String}         lkNm               【必须】湖泊名称
     * @apiParam   {Double}         watA               水面面积
     * @apiParam   {String}         sfwProp            咸淡水属性
     * @apiParam   {Double}         avgDep             平均水深
     * @apiParam   {Double}         maxDep             最大水深
     * @apiParam   {Double}         lkV                湖泊容积
     * @apiParam   {Date}           ts                 【必须】时间戳
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest wr/lk/b/F42A201/update
     * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     * }
     * @apiUse exceptions
     */
    @PUT
    @Path("{lkCd:\\w{7}}/update")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response update(@PathParam("lkCd") String lkCd, WrLkB record) {
        record.setLkCd(lkCd);
        LOGGER.info("根据主键修改 湖泊基本信息表,参数 WrLkB:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(wrLkBService.updateByPrimaryKey(record)))).build();
    }

    /**
     * @api {put} wr/lk/b/{lkCd:\\w{7}}/update-selective [U][G]根据主键修改(只修改非null字段)
     * @apiPrivate
     * @apiDescription [G]根据主键修改WR_LK_B(湖泊基本信息表)数据,只修改非null字段
     * @apiName (generate)update selected data
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiParam   {String}         lkCd               湖泊代码
     * @apiParam   {String}         lkNm               湖泊名称
     * @apiParam   {Double}         watA               水面面积
     * @apiParam   {String}         sfwProp            咸淡水属性
     * @apiParam   {Double}         avgDep             平均水深
     * @apiParam   {Double}         maxDep             最大水深
     * @apiParam   {Double}         lkV                湖泊容积
     * @apiParam   {Date}           ts                 时间戳
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest wr/lk/b/F42A201/update-selective
     * * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     * }
     * @apiUse exceptions
     */
    @PUT
    @Path("{lkCd:\\w{7}}/update-selective")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response updateSelective(@PathParam("lkCd") String lkCd, WrLkB record) {
        record.setLkCd(lkCd);
        LOGGER.info("根据主键修改(只修改非null字段) 湖泊基本信息表,参数 WrLkB:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(wrLkBService.updateByPrimaryKeySelective(record)))).build();
    }

    /**
     * @api {post} wr/lk/b/updateBatch [U][G]根据主键批量修改(只修改非null字段)
     * @apiPrivate
     * @apiDescription [G]根据批量主键修改WR_LK_B(湖泊基本信息表)数据,只修改非null字段
     * @apiName (generate)updateBatch selected data
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiParam   {String}         lkCd               湖泊代码
     * @apiParam   {String}         lkNm               湖泊名称
     * @apiParam   {Double}         watA               水面面积
     * @apiParam   {String}         sfwProp            咸淡水属性
     * @apiParam   {Double}         avgDep             平均水深
     * @apiParam   {Double}         maxDep             最大水深
     * @apiParam   {Double}         lkV                湖泊容积
     * @apiParam   {Date}           ts                 时间戳
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest  wr/lk/b/updateBatch
     * * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * [{
     * "lkCd": "F42A201",
     * "lkNm": "洪湖",
     * "watA": 308,
     * "sfwProp": "1",
     * "avgDep": null,
     * "maxDep": null,
     * "lkV": null,
     * "ts": "2015-01-05 17:58:00.0",
     * "nt": null
     * }]
     * @apiUse exceptions
     */
    @POST
    @Path("updateBatch")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response updateBatch(List<WrLkB> record) {
        LOGGER.info("根据主键批量修改(只修改非null字段) 湖泊基本信息表,参数 WrLkB:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(wrLkBService.updateBatch(record)))).build();
    }

    /**
     * @api {delete} wr/lk/b/{lkCd:\\w{7}} [D][G]根据主键删除
     * @apiPrivate
     * @apiDescription [G]根据主键删除WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)delete by primary key
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiSampleRequest wr/lk/b/F42A201
     * @apiParam   {String}         lkCd               【必须】湖泊代码
     * @apiSuccess {Integer}        status             1:删除成功;0:要删除的数据不存在(可能已被删除).
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSuccessExample 删除成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 删除失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiUse exceptions
     */
    @DELETE
    @Path("{lkCd:\\w{7}}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response delete(@PathParam("lkCd") String lkCd) {
        LOGGER.info("根据主键删除 湖泊基本信息表,参数 lkCd:{}", lkCd);
        Integer rows = wrLkBService.deleteByPrimaryKey(lkCd);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.delete(rows))).build();
    }

    /**
     * @api {delete} wr/lk/b/by-filter [D][G]根据条件删除
     * @apiPrivate
     * @apiDescription [G]根据条件删除WR_LK_B(湖泊基本信息表)数据
     * @apiName (generate)delete by filter
     * @apiGroup WR_LK_B-湖泊基本信息表
     * @apiVersion 1.0.0
     * @apiSampleRequest wr/lk/b/by-filter
     * @apiParam   {List(String)}   lkCdList           (数组)湖泊代码
     * @apiParam   {String}         lkCd               湖泊代码
     * @apiParam   {String}         lkNm               湖泊名称
     * @apiParam   {Double}         watAMin            (最小)水面面积
     * @apiParam   {Double}         watAMax            (最大)水面面积
     * @apiParam   {List(String)}   sfwPropList        (数组)咸淡水属性
     * @apiParam   {Double}         avgDepMin          (最小)平均水深
     * @apiParam   {Double}         avgDepMax          (最大)平均水深
     * @apiParam   {Double}         maxDepMin          (最小)最大水深
     * @apiParam   {Double}         maxDepMax          (最大)最大水深
     * @apiParam   {Double}         lkVMin             (最小)湖泊容积
     * @apiParam   {Double}         lkVMax             (最大)湖泊容积
     * @apiParam   {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam   {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam   {String}         nt                 备注
     * @apiSuccess {Integer}        status             通常1或者>1:删除成功;0:没有符合条件的数据.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSuccessExample 删除成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 删除失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiUse exceptions
     */
    @DELETE
    @Path("by-filter")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response deleteByFilter(WrLkBQo filter) {
        LOGGER.info("根据条件删除 湖泊基本信息表,参数 WrLkBQo:{}", filter);
        Integer rows = wrLkBService.deleteByFilter(filter);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.delete(rows))).build();
    }
}
